package com.ficus.road.maintain.core.infrastructure.mongo.converter;

import org.bson.types.Binary;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;

/**
 * 这个convert可以将mongo存储用的Binary转为byte[]
 * <p>
 * 很神奇mongo居然不支持支持存BSON,还得写这个converter
 */
@WritingConverter
public class BinaryConverter implements Converter<Binary, byte[]> {
    @Override
    public byte[] convert(Binary source) {
        return source.getData();
    }

}
